home *** CD-ROM | disk | FTP | other *** search
-
- Listing 3.
-
- /* random.c */
-
- #define SL_RAND_MAX 32767
-
- static long next = 1;
-
- unsigned slrand()
- {
- next = next * 1103515245 + 12345;
- return((unsigned int) ((next / 65536) % 32768));
- }
-
- slsrand(seed)
- unsigned seed;
- {
- next = seed;
- }
-
- /* return a random number in the range 0 .. (limit - 1) */
- int slrandom(limit)
- unsigned limit;
- {
- long num;
-
- num = (long) slrand();
- return((int) ((num * limit) / (1L + SL_RAND_MAX)));
- }
-
-